<template>
  <div>
    <el-form style="width: 100%;margin-bottom: -10px;margin-top: -10px;">
      <el-form-item>
        <el-button size="mini" icon="el-icon-back" type="success" @click="returnRoomPapers">返回考场</el-button>
      </el-form-item>
    </el-form>
    <el-row :span="24">
       <el-col :span="18">
         <el-table  :data="scoreTableData" style="width: 100%">
           <el-table-column type="index" align="center" width="80"></el-table-column>
           <el-table-column align="center" label="id" prop="user.user_id"></el-table-column>
           <el-table-column align="center" label="用户名" prop="user.user_name"></el-table-column>
           <el-table-column align="center" label="昵称" prop="user.user_nick_name"></el-table-column>
           <el-table-column align="center" label="性别" prop="user.user_sex"></el-table-column>
           <el-table-column align="center" label="分数" prop="tsr_score"></el-table-column>
           <el-table-column align="center" label="测试时间" prop="tsr_text_time"></el-table-column>
         </el-table>
         <el-pagination
           @size-change="handleSizeChange"
           @current-change="handleCurrentChange"
           :current-page="pageInfo.page"
           :page-sizes="[30, 50, 80,100]"
           :page-size="pageInfo.size"
           layout="total, sizes, prev, pager, next, jumper"
           :total="pageInfo.total">
         </el-pagination>
       </el-col>

       <el-col :span="5" style="margin-left: 15px;">
         <el-table  :data="tableData" style="width: 100%">
           <el-table-column align="center" label="项目" prop="label"></el-table-column>
           <el-table-column align="center" label="统计" prop="value"></el-table-column>
         </el-table>
       </el-col>
    </el-row>
  </div>
</template>
<script>
  import{scoreStatistics,getScoreStatistics} from '@/api/invigilate'
  import ElCol from "element-ui/packages/col/src/col";
  export default{
    components: {ElCol},
    created(){
       this.getTableData();
    },
    data(){
        return {
          scoreTableData:[],
          tableData:[],

          pageInfo:{
            page:1,//页数
            size:10, //页面大小
            total:0 //页总数
          },
          requestData:{
            pageSize:30,
            pageNum:1,
            map:{
              rp_id:0
            }
          }
        }
      },
      methods:{
        getTableData(){
          this.requestData.map.rp_id = this.$route.query.rp_id;
          scoreStatistics(this.requestData).then(res=>{
              if(res.code == 200){
                  this.scoreTableData = res.data.data;
                  this.pageInfo.total = res.data.total;
              }
          });

          getScoreStatistics({rp_id:this.$route.query.rp_id}).then(res=>{
            if(res.code == 200){
                this.tableData = [
                  {label:"考试人数",value:res.data.peopleNum},
                  {label:"单选题平均分",value:res.data.choose},
                  {label:"多选题平均分",value:res.data.chooses},
                  {label:"判断题平均分",value:res.data.judgment},
                  {label:"填空题平均分",value:res.data.fillBanks},
                  {label:"平均分",value:res.data.score},
                ]
            }
          })
        },
        returnRoomPapers(){
          this.$router.push({ path: '/invigilate/examinationRoom/component/insertRoom/'+this.$route.query.id });
        },
        //每页的条数发生改变时调用
        handleSizeChange(size){
          this.requestData.pageSize = size;
          this.pageInfo.size = size;
          this.getTableData();
        },

        //页数发生改变时调用
        handleCurrentChange(page){
          this.requestData.pageNum = page;
          this.pageInfo.page = page;
          this.getTableData();
        },
      }
  }
</script>
